package hoang.android.app.json;

import hoang.android.app.info.WebServiceConfig;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;


/**
 * 
 * @author Apple
 *
 *day la lop de tao ra cac tham so de truyen len Server
 */

public class ParameterFactory {
	
	/**
	 * create parameters to get location list
	 * 
	 * tokenID=90f43e75b0d2ed4b9774792648ce4b87f957b580&action= loclist&toll_road=0&loc_id=0&timestamp=1321700334
	 * 
	 * @param tokenID
	 * @param action
	 * @param toll_road
	 * @param loc_id
	 * @return
	 */
	public static List<NameValuePair> createParamsLocList(String tokenID, String action, String toll_road, String loc_id){
		
		//phai dua vao API cua Webservice de biet nhung tham so nao duoc truyen len
		List<NameValuePair> parameters = new ArrayList<NameValuePair>();
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TOKEN_ID, tokenID));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ACTION, action));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TOLL_ROAD, toll_road));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_LOC_ID, loc_id));	
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TIME_STAMP, getTimeStamp()));
		
		return parameters;
	}
	
	public static String getTimeStamp(){
		
		Date date = new Date();
		return String.valueOf(date.getTime());
	}
	
	/**
	 * address_title=Mr&year2=2010&year1=2001&make2=ford&make1=ford&address_state=CA&model2=f150&plate2=pl103b&model1=focus&plate1=pl103a&email_address=sallen@thetollroads.com&address_middle_name=A&work_phone=1115556543&address_zipcode=92618&email_receipt=true&address_first_name=John&state2=GA&state1=CA&address_last_name=Martin&address_city=Irvine&action=userinfo&color2=brown&address1=103 Main&color1=white&vehicle_class=5to6&timestamp=1321700334
	 * 
	 * @param address_title
	 * @param address_first_name
	 * @param address_last_name
	 * @param address_middle_name
	 * @param address1
	 * @param address_city
	 * @param address_state
	 * @param address_zipcode
	 * @param work_phone
	 * @param email_address
	 * @param email_receipt
	 * @param vehicle_class
	 * @param plate1
	 * @param year1
	 * @param make1
	 * @param model1
	 * @param state1
	 * @param color1
	 * @param plate2
	 * @param year2
	 * @param make2
	 * @param model2
	 * @param state2
	 * @param color2
	 * @param action
	 * 
	 * @return
	 */
	public static List<NameValuePair> createParamsSubmitUserInfo(
			String address_title, 
			String address_first_name, 
			String address_last_name,
			String address_middle_name, 
			String address1, 
			String address_city, 
			String address_state, 
			String address_zipcode,
			String work_phone, 
			String email_address, 
			String email_receipt, 
			String vehicle_class, 
			String plate1, 
			String year1,
			String make1, 
			String model1, 
			String state1, 
			String color1, 
			String plate2, 
			String year2,
			String make2, 
			String model2, 
			String state2, 
			String color2, 
			String action){
		
		List<NameValuePair> parameters = new ArrayList<NameValuePair>();
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ADDRESS_TITLE, address_title));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ADDRESS_FIRST_NAME, address_first_name));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ADDRESS_LAST_NAME, address_last_name));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ADDRESS_MIDDLE_NAME, address_middle_name));
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ADDRESS1, address1));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ADDRESS_CITY, address_city));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ADDRESS_STATE, address_state));
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ADDRESS_ZIPCODE, address_zipcode));
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_WORK_PHONE, work_phone));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_EMAIL_ADDRESS, email_address));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_EMAIL_RECEIPT, email_receipt));
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_VEHICLE_CLASS, vehicle_class));
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_PLATE1, plate1));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_YEAR1, year1));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_MAKE1, make1));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_MODEL1, model1));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_STATE1, state1));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_COLOR1, color1));
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_PLATE2, plate2));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_YEAR2, year2));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_MAKE2, make2));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_MODEL2, model2));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_STATE2, state2));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_COLOR2, color2));
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ACTION_USER_INFO, action));
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TIME_STAMP, getTimeStamp()));
		
		return parameters;
	}
	
	public static List<NameValuePair> createParamsAddTrip(String tokenID, String start_date, String from_loc_id, String to_loc_id, String action){
		
		//phai dua vao API cua Webservice de biet nhung tham so nao duoc truyen len
		List<NameValuePair> parameters = new ArrayList<NameValuePair>();
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TOKEN_ID, tokenID));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ACTION, action));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_START_DATE, start_date));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_FROM_LOC_ID, from_loc_id));	
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TO_LOC_ID, to_loc_id));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TIME_STAMP, getTimeStamp()));
		
		return parameters;
	}
	
	public static List<NameValuePair> createParamsGetListTrip(String tokenID, String action){
		
		List<NameValuePair> parameters = new ArrayList<NameValuePair>();
		
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TOKEN_ID, tokenID));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ACTION, action));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TIME_STAMP, getTimeStamp()));
		
		return parameters;
	}
	
	public static List<NameValuePair> createParamsDeleteTrip(String tokenID, String trip_num, String action){
		
		List<NameValuePair> parameters = new ArrayList<NameValuePair>();
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TOKEN_ID, tokenID));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_ACTION, action));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TRIP_NUM, trip_num));
		parameters.add(new BasicNameValuePair(WebServiceConfig.PARAM_TIME_STAMP, getTimeStamp()));
		
		return parameters;
	}

}
